<div class="content">

   	<div class="list_button">
        <table cellpadding="0" cellspacing="0" border="0" width="100%" height="100%">
        <tr>
            <td>
                <?php
                    echo CHtml::link(
						"<div class='button'>" .
							"<div style='float:left; width:20px;'>" .
								CHtml::image(Yii::app()->baseUrl."/assets/icon/icon-16-plus.png") .
							"</div>" .
							"<div style='float:left; width:80px;'>".
								"Thêm mới" .
							"</div>" .
						"</div>"
						,
                        array($this->controller_id."/add","page"=>$page)
                    );
					
					echo "<div class='button' id='delete_multi'>" .
							"<div style='float:left; width:20px;'>" .
								CHtml::image(Yii::app()->baseUrl."/assets/icon/icon-16-remove.png") .
							"</div>" .
							"<div style='float:left; width:40px;'>".
								"Xóa" .
							"</div>" .
						"</div>";
                       
					 
                ?>
                <script session="javascript">
                $(document).ready(function(){
                    $('#delete_multi').click(function(){
                        var form = document.getElementById("form_table_all");
                        form.submit();
                    });	
                })
              </script>
            </td>
            
            <td align="right">
               
             </td>
          </tr>
        </table>
	</div>

    <table class="view">
        <tr height='25'>
            <th width="50px"> # </th>
            <th width="30">
                <?php 
                    echo CHtml::checkBox("checkbox_all", false, array("id"=>"checkbox_all"));
                ?>
            </th>
            <th colspan="2">Action</th>
            <th>Session ID</th>
            <th>Expire</th>
            <th width="400">Data</th>
            <th>Time online</th>
            <th>IP</th>
            <th>User ID</th>
        </tr>
        <?php
            if (! is_null($rows))
            {
                echo CHtml::beginForm(
					array(
						$this->controller_id."/delete_multi", 
						"page"=>$page
					),
					"post",
                    array("id"=>"form_table_all")
				);
                
                $i = 1;
                foreach($rows as $row)
                {
                    echo "<tr height='25'>";
                        echo "<td align='center'>";
                            echo $i++;
                        echo "</td>";
                        
                        echo "<td align='center'>";
                            echo CHtml::checkBox("cib[".$row["id"]."]", false, array("id"=>"cb".$i));
                        echo "</td>";
                        
                        echo "<td width='26px' align='center'>";
							$url = Yii::app()->createUrl(
								$this->route."/delete",
								array(
									"session_id" => $row->id,
									"page" => $page
								)
							);
							echo CHtml::image(
								Yii::app()->baseUrl.'/assets/icon/icon-16-trash.png',
								"",
								array(
									"style"=>"cursor:pointer",
									"title"=>"Delete",  
									"onClick"=>"javascript:actionDelete('".$url."');")
							);
							
                        echo "</td>";
                        
                        echo "<td width='26px' align='center'>";
                            echo CHtml::link(
                                CHtml::image(Yii::app()->baseUrl.'/assets/icon/icon-16-edit.png'),
                                array(
                                    $this->controller_id."/edit",
                                    "session_id" => $row["id"],
                                    "page" => $page
                                ),
                                array('title'=>'edit')
                            );
                        echo "</td>";
                            
                        echo "<td>";
                            echo CHtml::link(	
                                $row["id"],
                                array(
                                    $this->controller_id."/edit",
                                    'session_id' => $row["id"],
                                    "page" => $page
                                ),
                                array('title'=>'Edit')
                            );
                        echo "</td>";
                        
                        echo "<td align='center'>";
                           echo $row->expire;
                        echo "</td>";
                        
						echo "<td>";
                          echo $row->data;
                        echo "</td>";
						
						echo "<td align='center'>";
							echo $row->time_online;
                        echo "</td>";
						
						echo "<td align='center'>";
                           echo $row->ip_online;
                        echo "</td>";
						
						echo "<td align='center'>";
                           echo $row->user_id;
                        echo "</td>";
                    echo "</tr>";        
                }
                
                echo CHtml::endForm(); // end form
            }
        ?>
    </table>
</div><!-- end div content -->

<?php 
	// display pagination
	if ($pages->pageCount > 1)
	{
		echo "<div class='pagination'>";
			$this->widget('CLinkPager', array(
				'header' => "",
				'cssFile' => Yii::app()->baseUrl."/assets/css/pager.css",
				"prevPageLabel" => "«",
				"nextPageLabel" => "»",
				'pages' => $pages,
			));
			
			$this->widget('CListPager', array(
				//"promptText" => "Chuyển nhanh",
				"header" => "Trang ",
				'pages'=>$pages
			));
		echo "</div>";
	}
?>


<script session="javascript">

function actionDelete(url)
{
	if (confirm("Bạn muốn xóa mẫu tin này ?") == true)
		window.location = url;
}
	
</script>
    